<?php
namespace Modules\Page\Http\Controllers\Client\V1;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

use Modules\Page\Entities\Page;

use Validator;
use ThrowException;
use Auth;

class PageController extends Controller
{
    public function show(Request $req, $uuid)
    {
        $rule = [
        ];
        Validator::make($req->all(), $rule)->fails() && ThrowException::BadRequest(); 

        $item = Page::getEntity([
            'uuid' => $uuid
        ]);

        $info = $item->getInfo();

        $item->update([
            'visit_total' => $item->visit_total + 1
        ]);

        if ($item->status == 0) {
            ThrowException::Conflict('此页面已下架!');
        }

        return [
            'info' => $info
        ];
    }

}
